import request from "@/utils/request"
const scope = "scope_tbyf"
// 登录
export function login(username, password) {
  const grant_type = "password"
  return request({
    url: "/auth/oauth/token",
    method: "post",
    headers: {
      isToken: false,
      Authorization: "Basic c3lzdGVtX21ncjpzeXN0ZW1fbWdy"
    },
    params: { username, password, grant_type, scope }
  })
}
// 获取权限信息

// 获取路由信息
export function getRouters(token) {
  return request({
    url: "/upms/sysResource/getPublicRouters",
    method: "get"
  })
}
// 获取权限信息
export function getUserInfo(token) {
  return request({
    url: "/upms/user/publicInfo",
    method: "get"
  })
}
// 退出接口
export function logout() {
  return request({
    url: "/auth/token/logout",
    method: "delete"
  })
}
// export function getInfo(token) {
//   return request({
//     url: "/upms/user/info",
//     method: "get"
//   })
// }

// 更新token
export const refreshToken = refresh_token => {
  const grant_type = "refresh_token"
  return request({
    url: "/auth/oauth/token",
    headers: {
      isToken: false,
      Authorization: "Basic c3lzdGVtX21ncjpzeXN0ZW1fbWdy"
    },
    method: "post",
    params: { refresh_token, grant_type, scope }
  })
}
